<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>邀请好友</title>
    <link rel="stylesheet"  href="src/css/nativeShare.css?__version=9.4">
    <link rel="stylesheet"  href="src/css/base.css?__version=9.4">
    <link rel="stylesheet"  href="src/css/pages.css?__version=9.4">
    <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?8ed2efe5b24e14f351f4d88ba2eb3462";
      var s = document.getElementsByTagName("script")[0]; 
      s.parentNode.insertBefore(hm, s);
    })();
    </script>
</head>
<body>
    <div class="init_content" style="display: none;">
        <div class="warp invitation-warp contentbg">
            <div class="invitation_content">
                <img class="img" src="src/img/wawalogo.png">
                <div class="info"></div>
                <b class="code"></b>
            </div>
            <button class="btn share_wx btn-yellow">分享</button>
            <button class="btn share_q btn-yellow">分享二维码</button>
        </div>
        <div class="share_confirm">
            <div class="share_prompt" style="display: none;">
                <div>分享到微信，朋友圈，请点击<br/>右上角再选择【分享给朋友】</div>
            </div>
            <div id="nativeShare"></div>
        </div>
        <div class="share_img">
            <span class="closebtn"></span>
            <div class="heads">长按图片保存并发送给微信好友/朋友圈<br>好友扫码/通过链接进入游戏抓娃娃<br>您将至少获得<span style="color:#fff;"></span>金币<br></div>
            <div class="bodys"><img src=""></div>
        </div>
    </div>
    <div class="init_loading">
        <img src="src/img/page_loading.gif?v=1">
    </div>
    <div class="topalert"></div>
    <input id="motion_link1" type="text" name="link" value="" readonly="readonly" style="position:absolute;top:0;left:0;opacity: 0;" />
    <span id="motion_link" style="opacity: 0;"></span>
</body>
<script type="text/javascript" src="src/js/jquery-1.10.1.min.js?__version=9.4"></script>
<script type="text/javascript" src="src/js/rem.js?__version=9.4"></script>
<script type="text/javascript" src="src/js/nativeShare.js?__version=9.4"></script>
<script type="text/javascript" src="src/js/dropload.js?__version=9.4"></script>
<script type="text/javascript" src="src/js/init.js?__version=9.4"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="/src/js/share.js?__version=9.4"></script>
<script type="text/javascript">
    addheader("邀请好友","/personal.html");
    dropload(".warp");
    var recommendUrl='https://m.mxzhuawawa.com?recommend='+cookieGet("uid");
    $("#motion_link1").val(recommendUrl)
    $("#motion_link").html(recommendUrl)
    if(navigator.userAgent.indexOf('UCBrowser') > -1) {
        $(".share_prompt").hide();
        var urlImg = cookieGet("avatar");
        if (urlImg == null || urlImg == '') {
            var imageUrl = 'https://selfstore-1254316038.cosbj.myqcloud.com/logo.png';
        } else {
            var imageUrl = urlImg;
        }
        var config = {
            url:recommendUrl,
            title:'梦想抓娃娃',
            desc:'我玩儿这个游戏，你也来玩吧，给我送些金币!',
            img:imageUrl,
            img_title:"我玩儿这个游戏，你也来玩吧，给我送些金币!",
            from:'梦想抓娃娃-我玩儿这个游戏，你也来玩吧，给我送些金币!'
        };
        var share_obj = new nativeShare('nativeShare',config);
    }else{
        $(".share_prompt").show();
    }
    fetchData("/OpenAPI/v1/user/info",{"token":token},function(data){
        if(data.error){
            logout();
        }
    })
    $(document).on("click",".share_wx",function(){
        setShare();
        $(".share_confirm").show();
        _hmt.push(['_trackEvent', '微信分享', 'click', '分享', 1])
    })
    $(document).on("click",".share_q",function(){
        setShare();
        jsCopy();
        $(".share_img").show();
        _hmt.push(['_trackEvent', '图片分享或地址分享', 'click', '分享', 1])
    })
    $(document).on("click",".share_confirm",function(){
        $(this).hide();
    })
    $(document).on("click",".closebtn",function(){
        $(".share_img").hide();
    })

    fetchData("/OpenAPI/v1/app/referee",{"token":token},function(data){
        console.log(data);
        $(".invitation_content .info").html(data.referee_content_h5);
        $(".share_img .heads span").html(data.referee_value);
    });
    imgurl();
    function imgurl(){
        $.ajax({
            type:'get',
            url:api_url+'/OpenAPI/v1/user/getFixpic?uid='+cookieGet("uid"),
            success:function(data){
                console.log(data);
                $(".share_img .bodys img").attr("src",data+"?__version=9.4")
            }
        })
    }

    function jsCopy() {
        if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { //ios  
            var copyDOM = document.querySelector('#motion_link');  //要复制文字的节点    
            var range = document.createRange();      
            // 选中需要复制的节点    
            range.selectNode(copyDOM);    
            // 执行选中元素    
            window.getSelection().addRange(range);    
            // 执行 copy 操作    
            var successful = document.execCommand('copy');    
            try {      
                var msg = successful ? 'successful' : 'unsuccessful';  
                $(".topalert").html("分享链接已复制到剪切板").addClass("animate");
                setTimeout(function(){
                    $(".topalert").removeClass("animate");
                },2000) 
                console.log("复制成功")      
            } catch(err) {      
                console.log('Oops, unable to copy');      
            }    
            // 移除选中的元素    
            window.getSelection().removeAllRanges();    
        }else{  
            var value=document.getElementById("motion_link1");
                value.select(); //选择对象  
                document.execCommand("Copy"); //执行浏览器复制命令  
                $(".topalert").html("分享链接已复制到剪切板").addClass("animate");
                setTimeout(function(){
                    $(".topalert").removeClass("animate");
                },2000)
                console.log("复制成功") 
        }  
    }
</script>

</html>